package cn.aulang.study.ai.server.service;

import lombok.extern.slf4j.Slf4j;
import org.springframework.ai.tool.annotation.Tool;
import org.springframework.stereotype.Service;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;

/**
 * 时间服务
 *
 * @author Aulang
 */
@Slf4j
@Service
public class TimeService {

    private static final DateTimeFormatter DATE = DateTimeFormatter.ofPattern("yyyy-MM-dd");
    private static final DateTimeFormatter DATETIME = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");

    @Tool(description = "获取当前日期")
    public String getCurrentDate() {
        log.info("开始获取当前日期");
        String result = LocalDate.now().format(DATE);
        log.info("获取当前日期结果：{}", result);
        return result;
    }

    @Tool(description = "获取当前时间")
    public String getCurrentTime() {
        log.info("开始获取当前时间");
        String result = LocalDateTime.now().format(DATETIME);
        log.info("获取当前时间结果：{}", result);
        return result;
    }
}
